﻿using System;
using System.Globalization;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.DomainFramework.CacheService.EntityCacheKeyServices
{
	/// <summary>
	/// 
	/// </summary>
	public class CommandCacheKeyService : IEntityCacheKeyService
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="obj"></param>
		/// <returns></returns>
		public virtual string GenerateCacheKey(object obj)
		{
			var commandObj = obj as IEntityCommand<IEntityObject>;
			if (commandObj != null)
			{
				return string.Format(CultureInfo.InvariantCulture, "Command:{0} + {1}", commandObj.CommandName, commandObj.CacheKey);
			}
			throw new ArgumentOutOfRangeException("obj");
		}
	}
}